/**
 * 会员中心
 */
var app = getApp()
Page({
	data: {
		root:app.setting.att_url,
		pagedata:[],
		action: '',
		pagetitle:'微信会员卡' + '-' + app.setting.title,
		ShowAuthM:false,
		bannerHeight: Math.ceil(290.0 / 750.0 * getApp().screenWidth)
	},
	onReady: function (){
	},
	onShow: function (){
		var ssid=wx.getStorageSync('ssid');
		if(!ssid && !app.issession){
			app.util.session();
		}
	},
	onPullDownRefresh: function (){
		var the=this;
		var opt={};
		the.onLoad(opt);
		setTimeout(function(){
			wx.stopPullDownRefresh()
		},1000);
	},
	onLoad: function (options){
		var the = this;
		wx.setNavigationBarTitle({'title':the.data.pagetitle});
		the.getpagedata();
	},
	getpagedata: function (){
		var the=this;
		app.util.get(app.access,function(res){
			if(!res.member.nickname || !res.member.avatar){
				var fansinfo = wx.getStorageSync('userInfo');
				if(!fansinfo){
					var ShowAuthM=true
				}
			}
			the.setData({
				pagedata:res,
				ShowAuthM:ShowAuthM,
				pluginnav:app.session.menus,
				action:app.access.plugin+'/'+app.access.action+'/',
			});
			the.getcode();
		});
	},
	getcode: function (){
		var the=this;
		app.util.get('core/member.addwxcard//getcode=1',function(res){
			console.log('getcode');console.log(res)
			if(res.type=='error'){
				app.util.msg(res.message);
				return false;
			}
			var extraData=res.extraData		
			the.setData({
				extraData:extraData,
			});
		});
	},
	info_login:function(e){
		//根据openid为用户登陆，此处尝试获取用户信息
		var the=this;
		app.util.getUserInfo(e,function(res){
			the.getpagedata();
		});
		the.setData({
			ShowAuthM:false
		})
	},
	closeAuthM:function(){
		var the=this;
		the.setData({
			ShowAuthM:false
		})
	},
	click:function(evt){
		//用户点击事件 data.func 为方法名，data.params 为调用参数！
		var data=evt.currentTarget.dataset;
		//console.log(evt);
		app.util[data.func](data.params);
	}
})